//
//  SYTongJiNameView.m
//  SanYiTeaching
//
//  Created by 郑浩然 on 2019/4/26.
//  Copyright © 2019年 SanYi. All rights reserved.
//

#import "SYTongJiNameView.h"

@interface SYTongJiNameView ()

@property (strong, nonatomic) UIButton *selectBtn;

@end


@implementation SYTongJiNameView


- (void)awakeFromNib {
    [super awakeFromNib];
    [self.shitiBtn setTitle:@"按试题统计" forState:UIControlStateNormal];
    [self.shitiBtn setTitle:@"按试题统计" forState:UIControlStateSelected];
    [self.shitiBtn setTitleColor:[UIColor colorWithHexString:@"#20B097"] forState:UIControlStateNormal];
    [self.shitiBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];
    
    
    [self.xueshengBtn setTitle:@"按学生统计" forState:UIControlStateNormal];
    [self.xueshengBtn setTitle:@"按学生统计" forState:UIControlStateSelected];
    [self.xueshengBtn setTitleColor:[UIColor colorWithHexString:@"#20B097"] forState:UIControlStateNormal];
    [self.xueshengBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];
    
    self.kewenBtn.layer.borderWidth = 1;
    self.kewenBtn.layer.masksToBounds = YES;
    self.kewenBtn.layer.borderColor = [UIColor colorWithHexString:@"#20B097"].CGColor;
    self.kewenBtn.layer.cornerRadius = 5;
    [self.kewenBtn setTitle:@"按课文统计" forState:UIControlStateNormal];
    [self.kewenBtn setTitle:@"按课文统计" forState:UIControlStateSelected];
    [self.kewenBtn setTitleColor:[UIColor colorWithHexString:@"#20B097"] forState:UIControlStateNormal];
    [self.kewenBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];
    
    self.selectBtn = self.shitiBtn;
    self.selectBtn.selected = YES;
    self.selectBtn.backgroundColor = [UIColor colorWithHexString:@"#20B097"];
}


- (IBAction)selectBtnClick:(UIButton *)sender {
    NSInteger tag = sender.tag;
    SYTongJiNameViewType type = -1;
    switch (tag) {
        case 50://班级
            type = SYTongJiNameViewTypeBanJi;
            break;
        case 51://姓名
            type = SYTongJiNameViewTypeXingMing;
            break;
        case 52://试题
            type = SYTongJiNameViewTypeShiTi;
            self.selectBtn.selected = NO;
            self.selectBtn.backgroundColor = [UIColor whiteColor];
            self.selectBtn = sender;
            
            break;
        case 53://学生
            type = SYTongJiNameViewTypeXueSheng;
            self.selectBtn.selected = NO;
            self.selectBtn.backgroundColor = [UIColor whiteColor];
            self.selectBtn = sender;
            break;
        case 54://课文
            type = SYTongJiNameViewTypeKeWen;
            self.selectBtn.selected = NO;
            self.selectBtn.backgroundColor = [UIColor whiteColor];
            self.selectBtn = sender;
            
            break;
        default:
            
            break;
    }
    if ([self.delegate respondsToSelector:@selector(tongjiNameViewSelectBtnType:)]) {
        [self.delegate tongjiNameViewSelectBtnType:type];
    }
    self.selectBtn.selected = YES;
    self.selectBtn.backgroundColor = [UIColor colorWithHexString:@"#20B097"];
}



@end



























